package kz.simplex.photobox.model;
// Generated Jul 19, 2009 4:45:38 PM by Hibernate Tools 3.2.2.GA

import static javax.persistence.GenerationType.IDENTITY;

import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.hibernate.validator.Length;
import org.hibernate.validator.NotNull;

/**
 * Tags generated by hbm2java
 */
@Entity
@Table(name = "tags", catalog = "photobox")
public class Tag implements java.io.Serializable {
	private Integer id;
	private String label;
	private int tagsCount = 0;
	private Set<Photo> photos;
	private Set<Album> albums;

	public Tag() {
	}

	public Tag(String label, int tagsCount) {
		this.label = label;
		this.tagsCount = tagsCount;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}
	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "label", nullable = false, length = 16)
	@NotNull
	@Length(max = 16)
	public String getLabel() {
		return this.label;
	}
	public void setLabel(String label) {
		this.label = label;
	}

	@Column(name = "tagscount", nullable = false)
	public int getTagsCount() {
		return this.tagsCount;
	}
	public void setTagsCount(int tagsCount) {
		this.tagsCount = tagsCount;
	}

	@ManyToMany
	@JoinTable(name="tagsforphotos", joinColumns= @JoinColumn(name="tag", referencedColumnName="id"),
		    inverseJoinColumns=@JoinColumn(name="photo", referencedColumnName="ID"))
	public Set<Photo> getPhotos() {
		return photos;
	}
	public void setPhotos(Set<Photo> photos) {
		this.photos = photos;
	}

	@ManyToMany
	@JoinTable(name="tagsforalbums", joinColumns= @JoinColumn(name="tag", referencedColumnName="id"),
		    inverseJoinColumns=@JoinColumn(name="album", referencedColumnName="ID"))
	public Set<Album> getAlbums() {
		return albums;
	}
	public void setAlbums(Set<Album> albums) {
		this.albums = albums;
	}

}
